#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int P = 1e9+7, N = 1e6+10;
int n;
vector<int> G[N];
ll sz[N], F[N], D[N];
void up(ll&a, ll b){a = (a+b)%P;}

void dfs(int u, int f){
    F[u] = sz[u] = 1;

    for (auto v:G[u]){
        if(v==f) continue;
        dfs(v, u);
        sz[u] += sz[v];
        up(F[u], F[u]*F[v]);
    }

}

void dp(int u, int f){
    D[u] = F[u];
    if(u!=f){
        D[u] = (D[u] * (D[f]/(F[u]+1)+1))%P;
//        ll t = 0;
//        for(auto s:G[f]){
//            if(s == u) continue;
//            up(t, F[s]+1);
////            up(D[u], F[s]+1);
////            D[u] = (D[u]*(F[s]+1))%P;
////            up(D[u], D[u]*F[s]);
//        }
//        t += 1;
//        D[u] = (F[u]*t)%P;
    }
    for(auto v:G[u]){
        if(v==f) continue;
        dp(v, u);
    }
}

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n-1; ++i) {
        int a, b; cin >> a >> b;
        G[a].push_back(b), G[b].push_back(a);
    }
    dfs(1, 1);
    D[1] = F[1];
    dp(1, 1);
    for (int i = 1; i <= n; ++i) {
        cout << D[i]%P << '\n';
    }
    return 0;
}